package cn.iocoder.yudao.framework.datasource.provider;

import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DataSourceProperty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.sql.DataSource;
import java.util.Map;

/**
 * TODO
 *
 * @className: YmlDynamicDataSourceProvider
 * @author: tangkh
 * @date: 2023-09-19 17:01
 */
public class YmlDynamicDataSourceProvider extends AbstractDataSourceProvider implements DynamicDataSourceProvider {
    private static final Logger log = LoggerFactory.getLogger(YmlDynamicDataSourceProvider.class);
    private final Map<String, DataSourceProperty> dataSourcePropertiesMap;

    @Override
    public Map<String, DataSource> loadDataSources() {
        return this.createDataSourceMap(this.dataSourcePropertiesMap);
    }

    @Override
    public Map<String, DataSourceProperty> dataSourceProperties() {
        return this.dataSourcePropertiesMap;
    }

    public YmlDynamicDataSourceProvider(Map<String, DataSourceProperty> dataSourcePropertiesMap) {
        this.dataSourcePropertiesMap = dataSourcePropertiesMap;
    }
}
